﻿using System;
using System.Collections.Generic;

namespace Heimdallr
{
    /// <summary>
    /// Define a <see cref="ServiceElement"/> as a notification publisher which supports conditional notifying.
    /// </summary>
    /// <typeparam name="TTarget">The type of target.</typeparam>
    public interface IConditionalNotifyElement<TTarget> : INotifyElement
    {
        /// <summary>
        /// Gets all avaliable targets.
        /// </summary>
        IEnumerable<TTarget> AvailableTargets { get; }

        /// <summary>
        /// Publishes a notification to specified targets.
        /// </summary>
        /// <param name="notification">A notification which is going to be published.</param>
        /// <param name="targets">A collection of specified targets.</param>
        /// <exception cref="ArgumentNullException"><paramref name="notification"/> or <paramref name="targets"/> is null.</exception>
        /// <exception cref="InvalidOperationException">This element has not been started.</exception>
        /// <remarks>
        /// If <paramref name="targets"/> is an empty collection, the behavior of this method is the same as <see cref="INotifyElement.Publish(Notification)"/>.
        /// </remarks>
        void Publish(Notification notification, IEnumerable<TTarget> targets);
    }
}
